﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using KenLib.BusinessManager;

public partial class APP_frmA_JointCompBasicInfoRef : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ((APP_MasterPage_appCom)this.Master).changeTitle("送出し機関情報");
        ((APP_MasterPage_appCom)this.Master).HideLiArea("frmA_JointCompBasicInfoRef");
        if (!IsPostBack)
        {
            if (Session["役"] != null)
            {

                if (Request.QueryString["ID"] == null)
                {
                    Response.Redirect("frmA_TraineeList.aspx");
                }

                else
                {
                    string Str = Request.QueryString["ID"].ToString();
                    int Num;
                    bool isNum = int.TryParse(Str, out Num);
                    if (!isNum)
                    {
                        Response.Redirect("frmA_TraineeList.aspx");
                    }
                    this.Show();//  hien thi thong tin ve cong ty tiep nhan TNS co cung hiep hoi.
                }
            }
            else
            {
                Response.Redirect("~/frmD_Login.aspx");

            }
        }
        
    }

    public void Show()//  hien thi thong tin ve cong ty tiep nhan TNS co cung hiep hoi.
    {
        try
        {
            int 社員ID = Int32.Parse(Request.QueryString["ID"]);//Lay ID khi dang nhap
            本社情報Manager frm = new 本社情報Manager();
            DataTable dt = new DataTable();
            dt = frm.Select_frmA_JointCompBasicInfoRef(社員ID);
            if (dt.Rows.Count > 0)
            {
                foreach (DataRow row in dt.Rows)
                {
                    if (row["企業名"].ToString() != "")
                    {
                        lbl_送出し機関名.Text = row["企業名"].ToString();
                    }
                    else
                    {
                        lbl_送出し機関名.Text = "-";
                    }
                    if (row["設立年月日"].ToString() != "")
                    {
                        lbl_設立年月日.Text = ConvertDate(row["設立年月日"].ToString());
                    }
                    else
                    {
                        lbl_設立年月日.Text = "-";
                    }
                    if (row["企業名フリガナ"].ToString() != "")
                    {
                        lbl_フリガナ.Text = row["企業名フリガナ"].ToString();
                    }
                    else
                    {
                        lbl_フリガナ.Text = "-";
                    }
                    if (row["資本金"].ToString() != "")
                    {
                        lbl_資本金.Text = Convert.ToDecimal(row["資本金"]).ToString("###,###") + " VND";
                    }
                    else
                    {
                        lbl_資本金.Text = "-";
                    }
                    if (row["郵便番号"].ToString() != "")
                    {
                        lbl_郵便番号.Text = row["郵便番号"].ToString();
                    }
                    else
                    {
                        lbl_郵便番号.Text = "-";
                    }
                    if (row["住所"].ToString() != "")
                    {
                        lbl_住所.Text = row["住所"].ToString();
                    }
                    else
                    {
                        lbl_住所.Text = "-";
                    }
                    if (row["ＴＥＬ"].ToString() != "")
                    {
                        lbl_電話番号.Text = row["ＴＥＬ"].ToString();
                    }
                    else
                    {
                        lbl_電話番号.Text = "-";
                    }
                    if (row["FAX"].ToString() != "")
                    {
                        lbl_FAX番号.Text = row["FAX"].ToString();
                    }
                    else
                    {
                        lbl_FAX番号.Text = "-";
                    }
                    if (row["代表者１氏名"].ToString() != "")
                    {
                        lbl_氏名_代表者1.Text = ShowTextLength1(row["代表者１氏名"].ToString());
                        lbl_氏名_代表者1.ToolTip = row["代表者１氏名"].ToString();
                    }
                    else
                    {
                        lbl_氏名_代表者1.Text = "-";
                    }
                    if (row["代表者２氏名"].ToString() != "")
                    {
                        lbl_氏名_代表者2.Text = ShowTextLength1(row["代表者２氏名"].ToString());
                        lbl_氏名_代表者2.ToolTip = row["代表者２氏名"].ToString();
                    }
                    else
                    {
                        lbl_氏名_代表者2.Text = "-";
                    }
                    if (row["担当1氏名"].ToString() != "")
                    {
                        lbl_氏名_担当1.Text = ShowTextLength1(row["担当1氏名"].ToString());
                        lbl_氏名_担当1.ToolTip = row["担当1氏名"].ToString();
                    }
                    else
                    {
                        lbl_氏名_担当1.Text = "-";
                    }
                    if (row["担当２氏名"].ToString() != "")
                    {
                        lbl_氏名_担当2.Text = ShowTextLength1(row["担当２氏名"].ToString());
                        lbl_氏名_担当2.ToolTip = row["担当２氏名"].ToString();
                    }
                    else
                    {
                        lbl_氏名_担当2.Text = "-";
                    }
                    if (row["代表者１氏名フリガナ"].ToString() != "")
                    {
                        lbl_フリガナ_代表者1.Text = ShowTextLength1(row["代表者１氏名フリガナ"].ToString());
                        lbl_フリガナ_代表者1.ToolTip = row["代表者１氏名フリガナ"].ToString();
                    }
                    else
                    {
                        lbl_フリガナ_代表者1.Text = "-";
                    }
                    if (row["代表者２氏名フリガナ"].ToString() != "")
                    {
                        lbl_フリガナ_代表者2.Text = ShowTextLength1(row["代表者２氏名フリガナ"].ToString());
                        lbl_フリガナ_代表者2.ToolTip = row["代表者２氏名フリガナ"].ToString();
                    }
                    else
                    {
                        lbl_フリガナ_代表者2.Text = "-";
                    }
                    if (row["担当１氏名フリガナ"].ToString() != "")
                    {
                        lbl_フリガナ_担当1.Text = ShowTextLength1(row["担当１氏名フリガナ"].ToString());
                        lbl_フリガナ_担当1.ToolTip = row["担当１氏名フリガナ"].ToString();
                    }
                    else
                    {
                        lbl_フリガナ_担当1.Text = "-";
                    }
                    if (row["担当２氏名フリガナ"].ToString() != "")
                    {
                        lbl_フリガナ_担当2.Text = ShowTextLength1(row["担当２氏名フリガナ"].ToString());
                        lbl_フリガナ_担当2.ToolTip = row["担当２氏名フリガナ"].ToString();
                    }
                    else
                    {
                        lbl_フリガナ_担当2.Text = "-";
                    }
                    if (row["代表者１役職"].ToString() != "")
                    {

                        lbl_役職_代表者1.Text = ShowTextLength1(row["代表者１役職"].ToString());
                        lbl_役職_代表者1.ToolTip = row["代表者１役職"].ToString();
                    }
                    else
                    {
                        lbl_役職_代表者1.Text = "-";
                    }
                    if (row["代表者２役職"].ToString() != "")
                    {
                        lbl_役職_代表者2.Text = ShowTextLength1(row["代表者２役職"].ToString());
                        lbl_役職_代表者2.ToolTip = row["代表者２役職"].ToString();
                    }
                    else
                    {
                        lbl_役職_代表者2.Text = "-";
                    }
                    if (row["担当１役職"].ToString() != "")
                    {
                        lbl_役職_担当1.Text = ShowTextLength1(row["担当１役職"].ToString());
                        lbl_役職_担当1.ToolTip = row["担当１役職"].ToString();
                    }
                    else
                    {
                        lbl_役職_担当1.Text = "-";
                    }
                    if (row["担当２役職"].ToString() != "")
                    {
                        lbl_役職_担当2.Text = ShowTextLength1(row["担当２役職"].ToString());
                        lbl_役職_担当2.ToolTip = row["担当２役職"].ToString();
                    }
                    else
                    {
                        lbl_役職_担当2.Text = "-";
                    }
                    if (row["代表者１ＴＥＬ"].ToString() != "")
                    {
                        lbl_電話番号_代表者1.Text = ShowTextLength1(row["代表者１ＴＥＬ"].ToString());
                        lbl_電話番号_代表者1.ToolTip = row["代表者１ＴＥＬ"].ToString();
                    }
                    else
                    {
                        lbl_電話番号_代表者1.Text = "-";
                    }
                    if (row["代表者２ＴＥＬ"].ToString() != "")
                    {
                        lbl_電話番号_代表者2.Text = ShowTextLength1(row["代表者２ＴＥＬ"].ToString());
                        lbl_電話番号_代表者2.ToolTip = row["代表者２ＴＥＬ"].ToString();
                    }
                    else
                    {
                        lbl_電話番号_代表者2.Text = "-";
                    }
                    if (row["担当１直通ＴＥＬ"].ToString() != "")
                    {
                        lbl_電話番号_担当1.Text = ShowTextLength1(row["担当１直通ＴＥＬ"].ToString());
                        lbl_電話番号_担当1.ToolTip = row["担当１直通ＴＥＬ"].ToString();
                    }
                    else
                    {
                        lbl_電話番号_担当1.Text = "-";
                    }
                    if (row["担当２直通ＴＥＬ"].ToString() != "")
                    {
                        lbl_電話番号_担当2.Text = ShowTextLength1(row["担当２直通ＴＥＬ"].ToString());
                        lbl_電話番号_担当2.ToolTip = row["担当２直通ＴＥＬ"].ToString();
                    }
                    else
                    {
                        lbl_電話番号_担当2.Text = "-";
                    }
                }
            }
            else
            {
                lbl_送出し機関名.Text = "-";
                lbl_設立年月日.Text = "-";
                lbl_フリガナ.Text = "-";
                lbl_資本金.Text = "-";
                lbl_郵便番号.Text = "-";
                lbl_住所.Text = "-";
                lbl_電話番号.Text = "-";
                lbl_FAX番号.Text = "-";
                lbl_氏名_代表者1.Text = "-";
                lbl_氏名_代表者2.Text = "-";
                lbl_氏名_担当1.Text = "-";
                lbl_氏名_担当2.Text = "-";
                lbl_フリガナ_代表者1.Text = "-";
                lbl_フリガナ_代表者2.Text = "-";
                lbl_フリガナ_担当1.Text = "-";
                lbl_フリガナ_担当2.Text = "-";
                lbl_役職_代表者1.Text = "-";
                lbl_役職_代表者2.Text = "-";
                lbl_役職_担当1.Text = "-";
                lbl_役職_担当2.Text = "-";
                lbl_電話番号_代表者1.Text = "-";
                lbl_電話番号_代表者2.Text = "-";
                lbl_電話番号_担当1.Text = "-";
            }

        }
        catch { }
    }
    public string ConvertDate(string Day)// ham convert ngay thang nam.
    {
        if (Day == "")
        {
            return Day = "";
        }
        else
        {
            string ngay = Day;
            DateTime d1 = DateTime.Parse(ngay);
            return ngay = d1.ToString("yyyy年MM月dd日");
        }
    }

    public string ShowTextLength1(string temp)
    {
        //tieng viet
        if (temp.Length > 12)
            temp = temp.Substring(0, 12) + "...";
        if (temp.Length == 0)
        {
            temp = "";
        }
        return temp;

    }
}
